﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Text;

namespace Grade
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

       

        protected void btninser1_Click(object sender, EventArgs e)
        {
            string strCn = "server=pc.hstc.cn;database=dhd2014112118;uid=2014112118;pwd=19931028";
            SqlConnection cn = new SqlConnection(strCn);
            StringBuilder sb = new StringBuilder(1024);
            sb.Append("INSERT INTO Student ");
            sb.Append("                (No, Name, Gender, College, Major) ");
            sb.Append("VALUES   (@No,@Name,@Gender,@College,@Major) ");
            SqlParameter[] pms = new SqlParameter[5];
            pms[0] = new SqlParameter("@No", this.txtno.Text);
            pms[1] = new SqlParameter("@Name", this.txtname.Text);
            pms[2] = new SqlParameter("@Gender", this.txtgen.Text);
            pms[3] = new SqlParameter("@College", this.txtcol.Text);
            pms[4] = new SqlParameter("@Major", this.txtmajor.Text);
            int intResult = SqlHelper.ExecuteNonQuery(sb.ToString(), pms);
            this.lbl1.Text = (intResult < 1) ? "新增失败！" : "新增成功";
        }

        

        
    }
}